<template>
  <div class="app-container">
    <div class="block">
      <el-row :gutter="24">
        <el-col :span="4">
          <el-date-picker type="date" size="mini" placeholder="起始日期" v-model="listQuery.beginTime" value-format="yyyy-MM-dd"
                          style="width: 100%;"></el-date-picker>
        </el-col>
        <el-col :span="4">
          <el-date-picker type="date" size="mini" placeholder="结束日期" v-model="listQuery.endTime" value-format="yyyy-MM-dd"
                          style="width: 100%;"></el-date-picker>
        </el-col>
        <el-col :span="4">
            <el-select v-model="listQuery.criteria.noticeType" size="mini" placeholder="消息类型">
              <el-option
                v-for="item in noticeTypeList"
                :key="item.code"
                :label="item.type"
                :value="item.code">
              </el-option>
            </el-select>
          </el-col>
          <el-col :span="4">
            <el-select v-model="listQuery.criteria.state" size="mini" placeholder="读取状态">
              <el-option
                label="未读"
                value="false">
              </el-option>
              <el-option
                label="已读"
                value="true">
              </el-option>
            </el-select>
          </el-col>

        <el-col :span="8">
          <el-button type="success" size="mini" icon="el-icon-search" @click.native="search">搜索</el-button>
          <el-button type="primary" size="mini" icon="el-icon-refresh" @click.native="reset">重置</el-button>
          <el-button type="danger" size="mini" icon="el-icon-delete" @click.native="clear" >清空</el-button>
        </el-col>
      </el-row>
      <br>

    </div>

    <el-table :data="list" v-loading="listLoading" element-loading-text="Loading" border fit highlight-current-row
      > 
   <el-table-column label="标题">
        <template slot-scope="scope">
          {{ scope.row.title }}
        </template>
      </el-table-column>
      <el-table-column label="读取状态">
        <template slot-scope="scope">
          <el-tag type="success" v-if="scope.row.state == true">已读</el-tag>
          <el-tag type="warning" v-if="scope.row.state == false">未读</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="发布时间">
        <template slot-scope="scope">
          {{ formatDate(scope.row.publishTime) }}
        </template>
      </el-table-column>
      <el-table-column label="读取时间">
        <template slot-scope="scope">
          {{ formatDate(scope.row.readTime) }}
        </template>
      </el-table-column>

      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button type="text" size="mini" icon="el-icon-view" @click.native="show(scope.row)">查看</el-button>
          <el-button type="text" size="mini" icon="el-icon-delete" @click.native="remove(scope.row.id)">删除</el-button>
        </template>
      </el-table-column>


      
    </el-table>

    <el-pagination
      background
      layout="total, sizes, prev, pager, next, jumper"
      :page-sizes="[10, 20, 50, 100,500]"
      :page-size="listQuery.limit"
      :total="total"
      :current-page.sync="listQuery.page"
      @size-change="changeSize"
      @current-change="fetchPage"
      @prev-click="fetchPrev"
      @next-click="fetchNext">
    </el-pagination>

    <el-dialog :title="selRow.title" :visible.sync="centerDialogVisible" width="30%" center>
      <span style="font-size: 15px;">{{ " " + selRow.content }}</span>
      <span slot="footer" class="dialog-footer">
        <el-button @click="centerDialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="readNotice(selRow.id)" v-if="!selRow.state">已 读</el-button>
      </span>
    </el-dialog>

  </div>
</template>

<script src="./new.js"></script>
<style rel="stylesheet/scss" lang="scss" scoped>
  @import "src/styles/common.scss";
</style>
